﻿//SecurityPickerWindow.xaml.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Xaml
{
	using System.Collections.Generic;
	using System.Windows;

	using StockSharp.BusinessEntities;

	/// <summary>
	/// Окно выбора инструмента.
	/// </summary>
	public partial class SecurityPickerWindow
	{
		/// <summary>
		/// Создать <see cref="SecurityPicker"/>.
		/// </summary>
		public SecurityPickerWindow()
		{
			InitializeComponent();
		}

		///<summary>
		/// Выбранный инструмент.
		///</summary>
		public Security SelectedSecurity
		{
			get { return Picker.SelectedSecurity; }
			set { Picker.SelectedSecurity = value; }
		}

		///<summary>
		/// Выбранные инструменты.
		///</summary>
		public IList<Security> SelectedSecurities
		{
			get { return Picker.SelectedSecurities; }
		}

		/// <summary>
		/// Доступные инструменты.
		/// </summary>
		public IList<Security> Securities
		{
			get { return Picker.Securities; }
		}

		/// <summary>
		/// Шлюз к торговой системе.
		/// </summary>
		public ITrader Trader
		{
			get { return Picker.Trader; }
			set { Picker.Trader = value; }
		}

		private void PickerSecurityDoubleClick(Security security)
		{
			SelectedSecurity = security;
			DialogResult = true;
		}

		private void PickerSecuritySelected(Security security)
		{
			OkBtn.IsEnabled = security != null;
		}

		private void OkBtn_OnClick(object sender, RoutedEventArgs e)
		{
			DialogResult = true;
		}
	}
}